home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / doBakeSimulationArgList.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  5.8 KB  |  185 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //  Alias|Wavefront Script File
  18. //  MODIFY THIS AT YOUR OWN RISK
  19. //
  20. //  Creation Date:  10 Aug 98
  21. //  Author:         mw
  22. //
  23. //    Procedure Name:
  24. //        doBakeSimulationArgList
  25. //
  26. //    Description:
  27. //        This is the actual function that calls from the "Bake Simulation"
  28. //        option box.
  29. //
  30. //    Input Arguments:
  31. //    $version: The version of this option box.  Used to know how to 
  32. //    interpret the $args array.
  33. //        "1" : $useTS, $start, $end, $by, $below, $control, $shapes, $imp, $useCB
  34. //        "2" : $preserveOutsideKeys
  35. //        "3" : $selectionConnection
  36. //    
  37. //    $args
  38. //    Version 1
  39. //    [0]        $whichRange    1 : use the playback range
  40. //                        !(1) : use the $start and $end values
  41. //    [1]        $start        only applicable if $whichRange is 2
  42. //    [2]        $end        only applicable if $whichRange is 2
  43. //    [3]        $by            the increment from start to end time of simulation
  44. //                        with which to view frames and capture keyframes
  45. //    [4]        $below        0/1 : bake on selected items only, or all below
  46. //    [5]        $control    0/1 : if 1 and a transform above a shape is selected,
  47. //                            bake animation of all control points also
  48. //    [6]        $shapes        0/1 : if 1 and a transform above a shape is selected,
  49. //                            bake attributes of shape as well
  50. //                            (excluding control points)
  51. //    [7]        $imp        0/1 : if we're baking attributes that are controlled by an
  52. //                            implicit animation (i.e. with no explicit DG connections),
  53. //                            then if 1, turn off this implicit control after the
  54. //                            bake is complete (e.g. turn off the IK handle's
  55. //                            effects after baking skeleton joints, controlled by IK)
  56. //    [8]        $useCB        0/1 : if 1, set keyframes on attrs specified in channel box
  57. //    Version 2
  58. //    [9]        $preserveOutsideKeys 0/1 : if 1, preserve keys that are ouside the bake
  59. //                                 range when there are directly connected anim 
  60. //                                 curves
  61. //    Version 3
  62. //    [10]    $selectionConnection name of selection connection to use
  63. //  [11]    $sparseAnimCurveBake 0 : insert a key at every time step
  64. //                                 1 : do not insert new keys into ranges
  65. //                               where animation is defined, and try to
  66. //                               use as few keys as possible to bake the
  67. //                               pre and post infinity behavior
  68. //
  69. //    Return Value:
  70. //        None
  71. //
  72. global proc doBakeSimulationArgList (string $version, string $args[])
  73. {
  74.     int        $versionNum                = $version;
  75.  
  76.     int        $whichRange                = $args[0];
  77.     float    $start                    = $args[1];
  78.     float    $end                    = $args[2];
  79.     float    $by                        = $args[3];
  80.     int        $below                    = $args[4];
  81.     int        $control                = $args[5];
  82.     int        $shapes                    = $args[6];
  83.     int        $imp                    = $args[7];
  84.     int        $useCB                    = $args[8];
  85.     int        $preserveOutsideKeys    = ($versionNum >= 2 ? $args[9] : 0);
  86.     string    $selectionConnection    = ($versionNum >= 3 ? $args[10] : "animationList");
  87.     int     $sparseAnimCurveBake    = ($versionNum >= 3 ? $args[11] : 0);;
  88.  
  89.     string $cmd = "bakeResults -simulation true";
  90.  
  91.     if ($whichRange == 1 ) {
  92.         $cmd = ($cmd + 
  93.             " -t \"" + `playbackOptions -query -minTime` + ":" +
  94.             `playbackOptions -query -maxTime` + "\"");
  95.     }
  96.     else {
  97.         $cmd = ($cmd + " -t \""  + $start + ":" + $end + "\"");
  98.  
  99.  
  100.     }
  101.  
  102.     // Hierarchy election
  103.     //
  104.     if ($below) {
  105.         $cmd = $cmd + " -hierarchy below";
  106.     }
  107.  
  108.     // Sample By
  109.     //
  110.     $cmd = ( $cmd + " -sampleBy " + $by );
  111.  
  112.     // Disable Implicit Control
  113.     //
  114.     if ($imp)
  115.         $cmd = ($cmd + " -disableImplicitControl true");
  116.     else
  117.         $cmd = ($cmd + " -disableImplicitControl false");
  118.         
  119.     // Keep Unbaked Keys
  120.     //
  121.     if ($preserveOutsideKeys)
  122.         $cmd = ($cmd + " -preserveOutsideKeys true");
  123.     else
  124.         $cmd = ($cmd + " -preserveOutsideKeys false");
  125.  
  126.     // Sparse AnimCurve Bake
  127.     //
  128.     if ($sparseAnimCurveBake)
  129.         $cmd = ($cmd + " -sparseAnimCurveBake true");
  130.     else
  131.         $cmd = ($cmd + " -sparseAnimCurveBake false");
  132.  
  133.     // The Channel Box option determines both attributes AND target
  134.     // objects.
  135.     //
  136.     if( $useCB ) {
  137.         string  $syntax[] = keySetOptionBoxCommon( { "bakeSimulation", 
  138.                                                      "unknown", 
  139.                                                      "channelBoxSyntax" } );
  140.         if( size( $syntax[0] ) == 0 ) {
  141.             warning("No channels selected in channel box");
  142.             return;
  143.         }
  144.         
  145.         $cmd = ( $cmd + $syntax[0] );
  146.     }
  147.     // control points & shape  options only applicable without
  148.     // explicit channel box selection of attributes
  149.     //
  150.     else {
  151.         // Control points, shapes, elections
  152.         //
  153.         if ($control)
  154.             $cmd = ( $cmd + " -controlPoints true" );
  155.         else
  156.             $cmd = ( $cmd + " -controlPoints false" );
  157.  
  158.         if ($shapes)
  159.             $cmd = ($cmd + " -shape true");
  160.         else
  161.             $cmd = ($cmd + " -shape false");
  162.  
  163.         // Get the target objects
  164.         //
  165.         string $members = expandSelectionConnection ($selectionConnection);
  166.         
  167.         if( $members == "" ) {
  168.             $cmd = $cmd + " -animation objects";
  169.         }
  170.         else {
  171.             if ($members == "{}") {
  172.                 $cmd = "";
  173.                 warning ("No objects selected to bake simulation");
  174.             }
  175.             else {
  176.                 $cmd = ($cmd + " " + $members);
  177.             }
  178.         }
  179.     }
  180.  
  181.     if ($cmd != "") {
  182.         evalEcho($cmd);
  183.     }
  184. }
  185.